from web.forms.bootstrap import BootStrapForm
from django import forms
from web import models

class WikiModelForm(BootStrapForm,forms.ModelForm):

    class Meta:
        model = models.Wiki
        exclude = ['project','depth'] 

    def __init__(self,request,*args,**kwargs):
        super().__init__(*args,**kwargs)
        self.request = request

        # 找到想要的字段把它绑定显示数据重置
        # 数据 = 去数据库中获取 当前项目所有的wiki标题

        total_data_list = [("","---请选择---"),]
        data_list = models.Wiki.objects.filter(project=self.request.saas.project).values_list('id','title')
        total_data_list.extend(data_list)
        #self.fields['parent'].choices = [(1,'xxx',2'xxx)]
        self.fields['parent'].choices = total_data_list